﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server;
using MaxStudio.Concrete.Server.Service;
using MaxStudio.Concrete.Server.Dao; 

namespace MaxStudio.Concrete.Component
{
   public static class WebPartBind
    {
       public static void BindMasterDataDDL(DropDownList ddl, int masterTypeId)
       {
           MasterDataService masterDataServiceObj = ServiceFactory.getMasterDataService();

           OperationResult<List<tb_MasterData>> result = masterDataServiceObj.GetMasterDataByTypeId(masterTypeId);

           if (result.operationSuccess)
           {
               ddl.DataSource = result.obj;
               ddl.DataTextField = "Name";
               ddl.DataValueField = "Id";
               ddl.DataBind();
           }
           else
           {
               //TODO LOG
           }
       }

       public static void BindTrackingDDL(DropDownList ddl)
       {
           UserService userServiceObj = ServiceFactory.getUserService();

           OperationResult<List<tb_User>> result = userServiceObj.GetAllUserList();

           if (result.operationSuccess)
           {
               ddl.DataSource = result.obj;
               ddl.DataTextField = "CNName";
               ddl.DataValueField = "Id";
               ddl.DataBind();
           }
           else
           {
               //TODO LOG
           }
       }

    }
}
